# -*- coding: utf-8 -*-
# @Time    : 2024/12/1 下午8:01
# @Author  : wjx
# @Email   : kanxinxin@163.com
# @File    : collect_history.py
# @Software: PyCharm
from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


class CollectHistory(BasePage):
    # 点击浏览历史
    history_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("浏览历史")')
    # 查看第一个
    select_first_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId('
                                                    '"com.xiachufang:id/common_item_container").instance(0)')
    # 点击编辑
    edit_history_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId('
                                                    '"com.xiachufang:id/img_container").instance(1)')
    # 点击全部选择
    select_all_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/tv_right")')
    # 点击删除
    delete_history_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/tv_delete")')
    # 点击确认删除
    sure_delete_history_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId("com.xiachufang:id/tv_right")')
    # 课程
    course_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("课程")')
    # 断言
    result_tips_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("你还未浏览过菜谱")')

    def click_history(self):
        """
        点击浏览历史
        :return: None
        """
        self.find_element(self.history_locator).click()

    def click_select_first(self):
        """
        点击查看第一个
        :return: None
        """
        self.find_element(self.select_first_locator).click()

    def click_edit_history(self):
        """
        点击编辑
        :return:None
        """
        self.find_element(self.edit_history_locator).click()

    def click_select_all(self):
        """
        点击选择全部
        :return: None
        """
        self.find_element(self.select_all_locator).click()

    def click_delete(self):
        """
        点击删除
        :return:None
        """
        self.find_element(self.delete_history_locator).click()

    def click_sure_delete(self):
        """
        点击确认删除
        :return: None
        """
        self.find_element(self.sure_delete_history_locator).click()

    def click_course(self):
        """
        点击课程
        :return:None
        """
        self.find_element(self.course_locator).click()

    def get_result_tips(self):
        """
        获取所有历史删除完成后的页面内容
        :return: 所有历史删除完成后的页面内容
        """
        return self.find_element(self.result_tips_locator).text
